package com.suddev.bigdata.query

import com.suddev.bigdata.core.DemoApp
import com.suddev.bigdata.utils.ContextUtils
import com.vividsolutions.jts.geom.{Coordinate, Envelope, Geometry, GeometryFactory}
import org.datasyslab.geospark.spatialOperator.{KNNQuery, RangeQuery}

import scala.collection.JavaConversions._
import com.suddev.bigdata.utils.ImplicitAspect._

/**
  *
  * @author Rand
  * @date 2020/2/9 0009
  */
object QueryApp {
  def main(args: Array[String]): Unit = {
    implicit val sc = ContextUtils.getSparkContext(this.getClass.getSimpleName)
//    val objectRDD = DemoApp.createPointRDD
//    objectRDD.rawSpatialRDD.rdd.printInfo()
    val geometryFactory = new GeometryFactory()
    val pointObject = geometryFactory.createPoint(new Coordinate(-88.331495,32.324149))
    val K = 1 // K Nearest Neighbors
    val usingIndex = false
//    val result = KNNQuery.SpatialKnnQuery(objectRDD, pointObject, K, usingIndex)
//    result.foreach(println)
    val rangeQueryWindow = new Envelope(-90.00, -85.00, 30.00, 35.00)
    val considerBoundaryIntersection = false // Only return gemeotries fully covered by the window
//    var queryResult = RangeQuery.SpatialRangeQuery(objectRDD, rangeQueryWindow, considerBoundaryIntersection, usingIndex)
//    queryResult.rdd.printInfo()
  }
}
